package com.ruoyi.yljf.controller.AppController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.security.annotation.Anonymous;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.yljf.domain.BookCategory;
import com.ruoyi.yljf.service.IBookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 书籍分类Controller
 * 
 * @author metaee
 * @date 2025-02-12
 */
@Anonymous
@RestController
@RequestMapping("/api/category")
public class ApiBookCategoryController extends BaseController {
    @Autowired
    private IBookCategoryService bookCategoryService;

    /**
     * 查询书籍分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BookCategory bookCategory) {
        startPage();
        List<BookCategory> list = bookCategoryService.selectBookCategoryList(bookCategory);
        return getDataTable(list);
    }

    /**
     * 获取书籍分类详细信息
     */
    @GetMapping(value = "/{categoryId}")
    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId) {
        return success(bookCategoryService.getById(categoryId));
    }
    
}
